import request from '@/utils/request.js'
import {mergeRecursive} from "@/utils/ruoyi.js";

// 登录方法
export function login(username, password, code, uuid) {
    return request({
        url: '/auth/login',
        headers: {
            isToken: false
        },
        method: 'post',
        data: {username, password, code, uuid}
    })
}

// 手机号登录方法（无账号直接注册）
export function loginByPhone(phone, uuid, code) {
    return request({
        url: '/auth/phone',
        headers: {
            isToken: false
        },
        method: 'post',
        data: {phone, code, uuid}
    })
}

// 注册方法
export function register(username, password, confirmPassword, code, uuid) {
    return request({
        url: '/auth/register',
        headers: {
            isToken: false
        },
        method: 'post',
        data: {username, password, confirmPassword, code, uuid}
    })
}

// 刷新方法
export function refreshToken() {
    return request({
        url: '/auth/refresh',
        method: 'post'
    })
}

// 获取用户详细信息
export function getInfo() {
    return request({
        url: '/system/user/getInfo',
        method: 'get'
    })
}

// 退出方法
export function logout() {
    return request({
        url: '/auth/logout',
        method: 'delete'
    })
}

// 获取验证码
export function getCodeImg() {
    return request({
        url: '/code',
        headers: {
            isToken: false
        },
        method: 'get',
        timeout: 20000
    })
}

// 获取验证图片  以及token
export function getSwipeImg(type) {
    return request({
        url: '/gen',
        headers: {
            isToken: false
        },
        method: 'get',
        params: {type: type}
    })
}

// 滑动或者点选验证
export function swipeCheck(currentCaptchaId, data) {
    return request({
        url: "/check/",
        headers: {
            isToken: false
        },
        method: 'post',
        params: {id: currentCaptchaId},
        data: JSON.stringify(data),//schoolList是你要提交是json字符串
    })
}

// 滑动或者点选验证
export function getSms(query) {
    return request({
        url: "/auth/sms",
        method: 'get',
        params: query
    })
}
